﻿/**
 * B3DSprite
 *
 * @author		Justen Holter
 * @version		1.0
 *
 */
package com.justenholter.basic3d.objects {
	
	import com.justenholter.basic3d.B3DScene
	import com.justenholter.basic3d.objects.IRenderable;
	import flash.display.Sprite;
	
	public class B3DSprite extends Sprite implements IRenderable{
		
		private var xpos:Number;
		private var ypos:Number;
		private var zpos:Number;
		
		override public function get x():Number {
			return xpos;
		}
		
		override public function get y():Number {
			return ypos;
		}
		
		public function get z():Number {
			return zpos;
		}
		
		override public function set x(value:Number):void {
			xpos = value;
		}
		
		override public function set y(value:Number):void {
			ypos = value;
		}
		
		public function set z(value:Number):void {
			zpos = value;
		}
		
		/**
		 * B3DSprite
		 * 
		 * @param	xpos		Number		x position
		 * @param	ypos		Number		y position
		 * @param	zpos		Number		z position
		 */
		public function B3DSprite(x:Number = 0, y:Number = 0, z:Number = 0){
			this.x = x;
			this.y = y;
			this.z = z;
		}
		
		/**
		 * 
		 * @param	scene	Number		B3DScene rendering the object
		 * @param	scale	Number		float based on a objects new z used to represent
		 * 								the scale/perspective to render object
		 * @param	x		Number		new x position based on scene
		 * @param	y		Number		new y position based on scene
		 * @param	z		Number		new z positon based on scene
		 */
		public function render(scene:B3DScene, scale:Number, x:Number, y:Number, z:Number):void {
			
			//position
			super.x = scene.vp.x + scale * x;
			super.y = scene.vp.y - scale * y;
			
			//scale
			this.scaleX =
			this.scaleY = scale;
			
			//visibility
			this.visible = Boolean(scale);
		}
	}
}